import java.util.*;


public class Solution {
    /**
     * 解码
     * @param nums string字符串 数字串
     * @return int整型
     */

    public int solve (String nums) {
        // write code here

        if (nums.equals("0"))
            return 0;

        int[] ret = new int[nums.length() + 1];
        ret[0] = 1;
        ret[1] = 1;

        for (int i = 2; i <= nums.length(); i++) {
            if (nums.charAt(i - 1) == '0' && (nums.charAt(i - 2) != '1' && nums.charAt(i - 2) != '2'))
                return 0;
            if (nums.charAt(i - 2) == '2' && nums.charAt(i - 1) < '7' && nums.charAt(i - 1) > '0' || nums.charAt(i - 2) == '1' && nums.charAt(i - 1) != '0')
                ret[i] = ret[i - 2] + ret[i - 1];
            else 
                ret[i] = ret[i - 1];
        }

        return ret[nums.length()];
    }
}